package com.book.service;

import com.book.dao.classroomDao;
import com.book.dao.orderDao;
import com.book.po.classroom;
import com.book.po.order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class orderService {

    @Autowired
    private orderDao orderDao;


    public List<order> order_select(String id){
        return orderDao.order_select(id);
    };

    public String order_insert(order order, classroom classroom){
        String sid = order.getSid();
        List<order> orders = orderDao.order_select(sid);
        if (orders.size()!=0){
            return "用户已进行预约，请勿重复预约！";
        }
        else
        if (orderDao.order_insert(order)!=0){
            orderDao.index_update_jian(classroom);
            return "预约成功";
        }else {
            return "预约失败";
        }
    };
//
    public String order_delete(String sid){
        orderDao.index_update_jia(sid);
        if (orderDao.order_delete(sid)!=0){

            return "预约取消成功";
        }else {
            return "预约取消失败";
        }
    }
//
//    public String book_update(Book book){
//        if (bookDao.book_update(book)!=0){
//            return "修改成功";
//        }else {
//            return "修改失败";
//        }
//    }
}
